
```bash
cp kubernetes/server/bin/{kubeadm,kubelet} /usr/local/bin

cat > /lib/systemd/system/kubelet.service<<EOF
[Unit]
Description=kubelet: The Kubernetes Node Agent
Documentation=https://kubernetes.io/docs/
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/local/bin/kubelet
Restart=always
StartLimitInterval=0
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

sudo mkdir -p /lib/systemd/system/kubelet.service.d

cat >/lib/systemd/system/kubelet.service.d/10-kubeadm.conf<<EOF
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/sysconfig/kubelet
ExecStart=
ExecStart=/usr/local/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS
EOF

sudo systemctl enable --now kubelet
```














kubeadm config images list --kubernetes-version=v1.24.0 > images.list



sed -e 's#registry.k8s.io#registry.aliyuncs.com/google_containers#g' images.list > aliyun-images.list
ctr i pull registry.aliyuncs.com/google_containers/kube-apiserver:v1.33.4

# 使用docker pull下载镜像
while read -r image; do
  docker  pull $image
done < aliyun-images.list


# 保存镜像为tar文件，先修改tag为registry.k8s.io前缀
while read -r image; do
  # 提取镜像名和标签（例如从registry.aliyuncs.com/google_containers/pause:3.10中提取pause:3.10）
  image_name_tag=$(echo "$image" | awk -F'/' '{print $NF}')
  
  # 新的镜像名，前缀为registry.k8s.io
  new_image="vim /$image_name_tag"
  
  # 重命名镜像
  echo "正在重命名镜像: $image -> $new_image"
  docker tag "$image" "$new_image"
done < aliyun-images.list


# 保存镜像为tar文件，先修改tag为registry.k8s.io前缀
while read -r image; do
  # 提取镜像名和标签（例如从registry.aliyuncs.com/google_containers/pause:3.10中提取pause:3.10）
  image_name_tag=$(echo "$image" | awk -F'/' '{print $NF}')
  
  # 新的镜像名，前缀为registry.k8s.io
  new_image="vim /$image_name_tag"
  
  # 重命名镜像
  echo "正在重命名镜像: $image -> $new_image"
  docker tag "$image" "$new_image"
  
  # 生成保存的文件名（将:替换为_）
  name=$(echo "$image_name_tag" | sed 's/:/_/g')
  
  # 保存新命名的镜像为tar文件
  echo "正在保存镜像: $new_image -> ${name}.tar"
  docker save -o "${name}.tar" "$new_image"
done < aliyun-images.list


while read -r image; do
  # 提取镜像名和标签（例如从registry.aliyuncs.com/google_containers/pause:3.10中提取pause:3.10）
  image_name_tag=$(echo "$image" | awk -F'/' '{print $NF}')
  
  # 新的镜像名，前缀为registry.k8s.io
  new_image="registry.k8s.io/$image_name_tag"
  
  # 重命名镜像（ctr使用tag命令）
  echo "正在重命名镜像: $image -> $new_image"
  docker tag "$image" "$new_image"
done < aliyun-images.list


while read -r image; do
  # 提取镜像名和标签（例如从registry.aliyuncs.com/google_containers/pause:3.10中提取pause:3.10）
  image_name_tag=$(echo "$image" | awk -F'/' '{print $NF}')
  
  # 新的镜像名，前缀为registry.k8s.io
  new_image="registry.k8s.io/$image_name_tag"
  
  # 重命名镜像（ctr使用tag命令）
  echo "正在重命名镜像: $image -> $new_image"
  ctr image tag "$image" "$new_image"
done < aliyun-images.list